package com.webapp.api;


import java.util.Map;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.webapp.api.unicom.SybPayService;
import com.webapp.api.unicom.SybUtil;
import com.webapp.helper.StringUtil;
import com.webapp.helper.WechatData;
import com.webapp.model.OrderInfo;
import com.webapp.model.UserInfo;
import com.webapp.service.OrderInfoService;
import com.webapp.service.UserInfoService;
import com.webapp.view.Resp;






@RestController
public class DataController extends BaseController{
	
	private static final Logger LOGGER = LoggerFactory.getLogger(DataController.class);
	

	
	
	
	@Autowired
	private UserInfoService userInfoService;
	@Autowired
	private OrderInfoService orderInfoService;
	
	@RequestMapping(value = "/data/getOrderInfoByOutNo")
	public Resp getOrderInfoByOutNo(String outNo) {
		Resp resp = new Resp(false);
		try {
			if(StringUtil.isNotBlank(outNo)) {
				OrderInfo orderInfo = orderInfoService.getByOutNo(outNo);
				return new Resp(orderInfo);
			}
		} catch (Exception e) {
			LOGGER.error("e:{}",e);
		}
		return resp;
	}
	
	@RequestMapping(value = "/data/getOrderInfo")
	public Resp getOrderInfo(String orderNo) {
		Resp resp = new Resp(false);
		try {
			if(StringUtil.isNotBlank(orderNo)) {
				OrderInfo orderInfo = orderInfoService.getByOrderNo(orderNo);
				return new Resp(orderInfo);
			}
		} catch (Exception e) {
			LOGGER.error("e:{}",e);
		}
		return resp;
	}
	
	@RequestMapping(value = "/data/getUserInfo")
	public Resp getUserInfo(String openid,Integer type) {
		Resp resp = new Resp(false);
		try {
			if(StringUtil.isNotBlank(openid)) {
				UserInfo userInfo = userInfoService.findByfindByOpenid(openid,type);
				return new Resp(userInfo);
			}
		} catch (Exception e) {
			LOGGER.error("e:{}",e);
		}
		return resp;
	}
	

	
	
}
